package com.cskaoyan.wordmemorize.converter;

import com.cskaoyan.wordmemorize.dao.entity.UserCheckinDO;
import com.cskaoyan.wordmemorize.dao.entity.UserCheckinStatisticsDO;
import com.cskaoyan.wordmemorize.dto.admin.PageDTO;
import com.cskaoyan.wordmemorize.dto.app.UserCheckinDTO;
import com.cskaoyan.wordmemorize.dto.app.UserCheckinStatisticsDTO;
import com.cskaoyan.wordmemorize.request.UserCheckinCommand;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(componentModel = "spring")
public interface UserCheckinConverter {
    // Command 转 UserCheckinDO
    // @Mapping(target = "userId", expression = "java(Long.parseLong(command.getUserId()))")
    // @Mapping(target = "stickNo", ignore = true)
    // @Mapping(target = "updatedTime", ignore = true)
    UserCheckinDO userCheckinCommandToDO(UserCheckinCommand command);


    //DO 转 PageDTO
    @Mapping(source = "userCheckinDOS", target = "pageList")
    @Mapping(source = "count", target = "totalCount")
    PageDTO<UserCheckinDTO> levelDOToPageDTO(List<UserCheckinDO> userCheckinDOS, long count);
    // DO 转 DTO
    // @Mapping(target = "userId", expression = "java(String.valueOf(doObj.getUserId()))")
    UserCheckinDTO doToDto(UserCheckinDO userCheckinDO);
    // DO 转 StatisticsDTO
    // @Mapping(target = "userId", expression = "java(String.valueOf(statisticsDo.getUserId()))")
    // @Mapping(target = "totalTime", expression = "java(String.valueOf(statisticsDo.getTotalTime()))")
    List<UserCheckinStatisticsDTO> statisticsDosToDtos(List<UserCheckinStatisticsDO> statisticsDos);
    UserCheckinStatisticsDTO statisticsDoToDto(UserCheckinStatisticsDO statisticsDo);

}
